/**
 * @module
 * @author: hjava
 * @since: 2017/2/21 13:03
 */

Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = __webpack_require__(/*! ../core */ "./src/core/index.ts");
var event_emitter_1 = __webpack_require__(/*! _Eutils/event-emitter */ "./src/extra/utils/event-emitter.ts");
var config_manager_1 = __webpack_require__(/*! ./managers/config-manager */ "./src/extra/managers/config-manager.ts");
var vcard_manager_1 = __webpack_require__(/*! ./managers/vcard-manager */ "./src/extra/managers/vcard-manager.ts");
var session_manager_1 = __webpack_require__(/*! ./managers/session-manager */ "./src/extra/managers/session-manager.ts");
var message_manager_1 = __webpack_require__(/*! ./managers/message-manager */ "./src/extra/managers/message-manager.ts");
var emoticon_manager_1 = __webpack_require__(/*! ./managers/emoticon-manager */ "./src/extra/managers/emoticon-manager.ts");
var uuid_1 = __webpack_require__(/*! _util/uuid */ "./src/core/utils/uuid.ts");
var parse_message_1 = __webpack_require__(/*! _Eutils/parse-message */ "./src/extra/utils/parse-message.ts");
var http_session_1 = __webpack_require__(/*! _http/http.session */ "./src/core/http/http.session.ts");
var base64_1 = __webpack_require__(/*! _util/base64 */ "./src/core/utils/base64.ts");
var log_1 = __webpack_require__(/*! ./utils/log */ "./src/extra/utils/log.ts");
var CONSTANT = __webpack_require__(/*! ./constant */ "./src/extra/constant.ts");
var ExtraSDK = /** @class */ (function () {
    function ExtraSDK(opts) {
        this.mtdx = null;
        this.constant = null;
        this.EVENT_NAME = event_emitter_1.EVENT_NAME;
        this.eventEmitter = event_emitter_1.default;
        this.HTTP = null;
        log_1.default.init(opts.logan, opts.closeConsoleLog);
        log_1.default.log('ExtraSDK::constructor');
        if (!opts.channelId && !opts.multiChannelIds) {
            log_1.default.error('初始化时缺少 channelId 或 multiChannelIds 参数，会导致 SDK 逻辑异常，已停止初始化，具体初始化参数见文档：https://developers.sankuai.com/mt/xm/dx-sdk-web/master/init/');
            return;
        }
        this.mtdx = new core_1.default(opts);
        this.HTTP = this.mtdx.HTTP;
        this.constant = this.mtdx.CONSTANT;
        this._initManagers(this.mtdx);
        config_manager_1.default.setInitOpts(opts);
    }
    ExtraSDK.getLogModule = function () {
        return log_1.default;
    };
    ExtraSDK.getUuid = function () {
        return uuid_1.default.next();
    };
    ExtraSDK.fromBase64ToMessage = function (data) {
        return (new http_session_1.default['MsgHistoryRes']()).parserFromBuffer(base64_1.default.b64toBA(data).buffer);
    };
    ExtraSDK.parseMessage = function (messageDatum) {
        return parse_message_1.default(messageDatum);
    };
    ExtraSDK.prototype._initManagers = function (mtdx) {
        var managerStore = {
            configManager: config_manager_1.default,
            vcardManager: vcard_manager_1.default,
            sessionManager: session_manager_1.default,
            messageManager: message_manager_1.default,
            emoticonManager: emoticon_manager_1.default
        };
        for (var key in managerStore) {
            managerStore[key].init(mtdx);
            this[key] = managerStore[key];
        }
    };
    ExtraSDK.MTDX = core_1.default;
    ExtraSDK.CONSTANT = CONSTANT; // 对外使用的所有常量，注意constant和EVENT_NAME不能删除，因为旧的业务都是使用这个进行接入的
    return ExtraSDK;
}());
exports.default = ExtraSDK;


//# sourceURL=webpack://MTDX/./src/extra/index.ts?